package com.yueqian.sort;

import java.util.Arrays;

/**
 * @author shkstart
 * @create 2021-01-14 17:55
 */
public class ChanceSort {
    public static void main(String[] args) {
        int[] a = {5, 1, 3, 1, 32, 8, 1};
        sort(a);
        System.out.println(Arrays.toString(a));
    }


    public static void sort(int[] a) {
        for (int i = 0; i < a.length - 1; i++) {
            int minCount = a[i];
            int minIndex = i;
            for (int j = i + 1; j < a.length; j++) {
                if (a[j] < minCount) {
                    minCount = a[j];
                    minIndex = j;
                }

            }
            int t = a[i];
            a[i] = a[minIndex];
            a[minIndex] = t;
        }
    }
}
